<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Example: Dial With a Surrounding Image</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <script src="../../build/yui/yui-min.js"></script>
</head>
<body>

<div id="doc">
    <h1>Example: Dial With a Surrounding Image</h1>

    
        <a href="#toc" class="jump">Jump to Table of Contents</a>
    

    <div class="yui3-g">
        <div id="main" class="yui3-u">
            <div class="content"><div class="intro">
<p>This example shows how to create a <code>Dial</code> widget using an image 
that surrounds (or is larger than) the Dial.</p>
</div>

<div class="example yui3-skin-sam">
    <style type="text/css">
.example {
    text-align:center;
    *text-align: left;
}
/* Adding some margin to allow for the image */
.yui3-dial{
    margin:0 0 20px 20px;
}

/* Here, we are just cleaning out the visible 
styles of the ring and the center button 
to allow for the images. */

/* Remove visible styles of the ring */
.yui3-skin-sam .yui3-dial-content .yui3-dial-ring{
    box-shadow: none;
    -moz-border-radius: none;
    -webkit-border-radius: none;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    background:none;
}

/* Remove visible style of the center button */
.yui3-skin-sam .yui3-dial-content .yui3-dial-center-button {
    box-shadow: none;
    -moz-border-radius: none;
    -webkit-border-radius: none;
    -moz-box-shadow: none;
    background:none;
}

/* Hide all VML ovals in IE. */
.yui3-skin-sam .yui3-dial-ring-vml v\:oval {
    visibility:hidden;
}

/* Show the marker and the handle ovals */
.yui3-skin-sam .yui3-dial-ring-vml .yui3-dial-marker-vml v\:oval,
.yui3-skin-sam .yui3-dial-ring-vml .yui3-dial-handle-vml v\:oval {
    visibility:visible;
}

/* Fill center button and ring so their backgrounds accept events in IE */
.yui3-skin-sam .yui3-dial-content .yui3-dial-center-button-vml,
.yui3-skin-sam .yui3-dial-content .yui3-dial-ring-vml{
    background:url(http://yuilibrary.com/yui/docs/assets/dial/images/empty.png);
}
</style>

    <div id="demo"></div>

<script>
YUI().use('dial', function(Y) {
    
    var dial = new Y.Dial({
        min: -90,
        max: 90,
        stepsPerRevolution: 200,
        value: 0,
        diameter: 100
    });
    dial.set('strings',{'label':'Climate:', 'resetStr':'Off', 'tooltipHandle':'Drag for cool or heat.'});
    dial.render('#demo');
    
    var im = Y.Node.create('<img src="http://yuilibrary.com/yui/docs/assets/dial/images/cold_hot.png"/>');
    im.setStyles({'position':'absolute', 'top':'-3px', 'left':'-9px'});
    Y.one('.yui3-dial-north-mark').insert(im, 'before');
    
});
</script>
</div>

<h3 id="creating-a-dial-and-surrounding-it-with-a-larger-image">Creating a Dial and Surrounding It With a Larger Image</h3>

<p>Some cases may require a <code>Dial</code> that has an image surrounding it such as tick marks, units, or other
visual enhancements. These images can be larger than the ring of the dial and therefore may not fit as a background image.
To provide for this use case, an extra image object will need to be added to the DOM.</p>

<p>
In this example we'll simulate the climate control on an car dashboard.
The image we'll add contains two curved wedges of color, blue and red, that wrap around the dial,
signifying the temperature of air conditioning or heat.
</p>

<h4 id="the-markup">The Markup</h4>

<p>The only markup requirement is a div to contain the <code>Dial</code>.</p>

<pre class="code prettyprint">&lt;div id=&quot;demo&quot;&gt;&lt;&#x2F;div&gt;</pre>


<h4 id="the-javascript">The JavaScript</h4>

<p>The same JavaScript can be used as in the basic Dial example, with a bit of
extra code to add the image object.</p>

<p>Some commonly used configuration attributes are shown below. 
This example also shows how to modify the visible UI strings before the <code>Dial</code> renders.</p>
<pre class="code prettyprint">YUI().use(&#x27;dial&#x27;, function(Y) {

    var dial = new Y.Dial({
        min: -90,
        max: 90,
        stepsPerRevolution: 200,
        value: 0,
        diameter: 100
    });
    &#x2F;&#x2F;Setting visible HTML strings before Dial renders.
    dial.set(&#x27;strings&#x27;,{&#x27;label&#x27;:&#x27;Climate:&#x27;, &#x27;resetStr&#x27;:&#x27;Off&#x27;, &#x27;tooltipHandle&#x27;:&#x27;Drag for cool or heat.&#x27;});
    dial.render(&quot;#demo&quot;);

});</pre>



<h4 id="inserting-the-image">Inserting the Image</h4>
<p>After rendering the <code>Dial</code>, we create and insert the image object.</p>
<pre class="code prettyprint">&#x2F;&#x2F;Create an image node.
var im = Y.Node.create(&#x27;&lt;img src=&quot;http:&#x2F;&#x2F;yuilibrary.com&#x2F;yui&#x2F;docs&#x2F;assets&#x2F;dial&#x2F;images&#x2F;cold_hot.png&quot;&#x2F;&gt;&#x27;);
    
&#x2F;&#x2F;Position it absolutely to the correct spot depending on it&#x27;s size.
im.setStyles({&#x27;position&#x27;:&#x27;absolute&#x27;, &#x27;top&#x27;:&#x27;-3px&#x27;, &#x27;left&#x27;:&#x27;-9px&#x27;});
    
&#x2F;&#x2F;Insert it in the DOM.
&#x2F;&#x2F;The north-mark is the first object inside the ring.
&#x2F;&#x2F;depending on the image, you may need to insert it before the yui3-dial-label 
Y.one(&#x27;.yui3-dial-north-mark&#x27;).insert(im, &#x27;before&#x27;);</pre>


<h4 id="the-css">The CSS</h4>
<p> 
In the CSS, we're just cleaning out the visible styles of the ring and the 
center button to allow for the images.
</p>

<h3 id="complete-example-source">Complete Example Source</h3>
<pre class="code prettyprint">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;script src=&quot;http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.4.0&#x2F;build&#x2F;yui&#x2F;yui-min.js&quot;&gt;&lt;&#x2F;script&gt;

&lt;style&gt;
&#x2F;* Adding some margin to allow for the image *&#x2F;
.yui3-dial{
    margin:0 0 20px 20px;
}

&#x2F;* Here, we are just cleaning out the visible 
styles of the ring and the center button 
to allow for the images. *&#x2F;

&#x2F;* Remove visible styles of the ring *&#x2F;
.yui3-skin-sam .yui3-dial-content .yui3-dial-ring{
    box-shadow: none;
    -moz-border-radius: none;
    -webkit-border-radius: none;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    background:none;
}

&#x2F;* Remove visible style of the center button *&#x2F;
.yui3-skin-sam .yui3-dial-content .yui3-dial-center-button {
    box-shadow: none;
    -moz-border-radius: none;
    -webkit-border-radius: none;
    -moz-box-shadow: none;
    background:none;
}

&#x2F;* Hide all VML ovals in IE. *&#x2F;
.yui3-skin-sam .yui3-dial-ring-vml v\:oval {
    visibility:hidden;
}

&#x2F;* Show the marker and the handle ovals *&#x2F;
.yui3-skin-sam .yui3-dial-ring-vml .yui3-dial-marker-vml v\:oval,
.yui3-skin-sam .yui3-dial-ring-vml .yui3-dial-handle-vml v\:oval {
    visibility:visible;
}

&#x2F;* Fill center button and ring so their backgrounds accept events in IE *&#x2F;
.yui3-skin-sam .yui3-dial-content .yui3-dial-center-button-vml,
.yui3-skin-sam .yui3-dial-content .yui3-dial-ring-vml{
    background:url(http:&#x2F;&#x2F;yuilibrary.com&#x2F;yui&#x2F;docs&#x2F;assets&#x2F;dial&#x2F;images&#x2F;empty.png);
}
&lt;&#x2F;style&gt;

&lt;body class=&quot;yui3-skin-sam&quot;&gt;
    &lt;div id=&quot;demo&quot;&gt;&lt;&#x2F;div&gt;
&lt;&#x2F;body&gt;

&lt;script&gt;
YUI().use(&#x27;dial&#x27;, function(Y) {
    
    var dial = new Y.Dial({
        min: -90,
        max: 90,
        stepsPerRevolution: 200,
        value: 0,
        diameter: 100
    });
    dial.set(&#x27;strings&#x27;,{&#x27;label&#x27;:&#x27;Climate:&#x27;, &#x27;resetStr&#x27;:&#x27;Off&#x27;, &#x27;tooltipHandle&#x27;:&#x27;Drag for cool or heat.&#x27;});
    dial.render(&#x27;#demo&#x27;);
    
    var im = Y.Node.create(&#x27;&lt;img src=&quot;http:&#x2F;&#x2F;yuilibrary.com&#x2F;yui&#x2F;docs&#x2F;assets&#x2F;dial&#x2F;images&#x2F;cold_hot.png&quot;&#x2F;&gt;&#x27;);
    im.setStyles({&#x27;position&#x27;:&#x27;absolute&#x27;, &#x27;top&#x27;:&#x27;-3px&#x27;, &#x27;left&#x27;:&#x27;-9px&#x27;});
    Y.one(&#x27;.yui3-dial-north-mark&#x27;).insert(im, &#x27;before&#x27;);
    
});
&lt;&#x2F;script&gt;
&lt;&#x2F;html&gt;</pre>

</div>
        </div>

        <div id="sidebar" class="yui3-u">
            
                <div id="toc" class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Table of Contents</h2>
                    </div>

                    <div class="bd">
                        <ul class="toc">
<li>
<a href="#creating-a-dial-and-surrounding-it-with-a-larger-image">Creating a Dial and Surrounding It With a Larger Image</a>
<ul class="toc">
<li>
<a href="#the-markup">The Markup</a>
</li>
<li>
<a href="#the-javascript">The JavaScript</a>
</li>
<li>
<a href="#inserting-the-image">Inserting the Image</a>
</li>
<li>
<a href="#the-css">The CSS</a>
</li>
</ul>
</li>
<li>
<a href="#complete-example-source">Complete Example Source</a>
</li>
</ul>
                    </div>
                </div>
            

            
                <div class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Examples</h2>
                    </div>

                    <div class="bd">
                        <ul class="examples">
                            
                                
                                    <li data-description="Create a Dial from existing markup on the page - a simple use case.">
                                        <a href="dial-basic.html">Basic Dial</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Link a Dial with a text input field.">
                                        <a href="dial-text-input.html">Dial Linked With Text Input</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Use image backgrounds to control the visual display of a Dial.">
                                        <a href="dial-image-background.html">Dial With Image Background</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Use images to surround a Dial instance and provide additional styling.">
                                        <a href="dial-image-surrounding.html">Dial With a Surrounding Image</a>
                                    </li>
                                
                            
                                
                                    <li data-description="This example employs Dial to drive an interactive UI.">
                                        <a href="dial-interactive.html">Dial With Interactive UI</a>
                                    </li>
                                
                            
                        </ul>
                    </div>
                </div>
            

            
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

</body>
</html>
